﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Subscriber
{
    public class AssignRecordLogic
    {
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static void Add(AssignRecordModel model, clsOleDB cls)
        {
            // Database db = DatabaseFactory.CreateDatabase();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into WF_ASSIGN_RECORDS(");
            strSql.Append("ID,ProcessName,Incident,Taskid,TskUser,TskAssignUser,TskAssignDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + model.ID + "',");
            strSql.Append("'" + model.ProcessName + "',");
            strSql.Append("" + model.Incident + ",");
            strSql.Append("'" + model.Taskid + "',");
            strSql.Append("'" + model.TskUser + "',");
            strSql.Append("'" + model.TskAssignUser + "',");
            strSql.Append("'" + model.TskAssignDate + "'");
            strSql.Append(")");
            cls.exeSql(strSql.ToString());
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(AssignRecordModel model, clsOleDB cls)
        {
            //  Database db = DatabaseFactory.CreateDatabase();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update WF_ASSIGN_RECORDS set ");
            strSql.Append("ID='" + model.ID + "',");
            strSql.Append("ProcessName='" + model.ProcessName + "',");
            strSql.Append("Incident=" + model.Incident + ",");
            strSql.Append("Taskid='" + model.Taskid + "',");
            strSql.Append("TskUser='" + model.TskUser + "',");
            strSql.Append("TskAssignUser='" + model.TskAssignUser + "',");
            strSql.Append("TskAssignDate='" + model.TskAssignDate + "'");
            strSql.Append(" where ID='" + model.ID + "' ");
            cls.exeSql(strSql.ToString());
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static bool Delete(string ID, clsOleDB cls)
        {
            // Database db = DatabaseFactory.CreateDatabase();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from WF_ASSIGN_RECORDS ");
            strSql.Append(" where ID='" + ID + "' ");
            //  DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            int rows = cls.exeSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
